package com.price.sample.http.service

import com.price.httplib.base.BaseHttpApiService
import com.price.sample.http.myinterface.EuropeanaApi
import okhttp3.Interceptor

/**
 * 非标准数据格式
 *  EuropeanaApiService 就是无法映射Http Base Wrapper Data，这里就只能自己判断数据是否成功了
 *
 */
object EuropeanaApiService : BaseHttpApiService() {

    override fun getServiceUrl(): String {
        return "https://api.europeana.eu/record/v2/"
    }

    override fun getInterceptor(): List<Interceptor> {
        val headerInterceptor=Interceptor { chain ->
            val builder = chain.request().newBuilder()
            builder.addHeader("Source", "source")
            chain.proceed(builder.build())
        }
        return listOf(headerInterceptor)
    }




    /**
     * 减少一点重复代码
     *
     */
    fun getService(): EuropeanaApi {
        return super.getService(EuropeanaApi::class.java)
    }


}

